import { Link, Tooltip } from "@mui/material";
import { GridActionsCellItem } from "@mui/x-data-grid";
import React from "react";
import { useEffect } from "react";
import { useState } from "react";
import { useContext } from "react";
import Dataform from "../../../components/Dataform";
import { TitleContext } from "../../../router";
import GetChipType from "../../teacher/CourseApplication/GetChipType";
import CheckIcon from "@mui/icons-material/Check";
import CloseIcon from "@mui/icons-material/Close";
import { renderCellExpand } from "../../../components/RenderCellExpand";
import GetDetail from "../../student/Quality/GetDetail";
const UrlRender = (param) => {
  return (
    <Link target="_blank" href={param.value} underline="none">
      论文链接
    </Link>
  );
};
const tmpCourse = [
  {
    id: 28,
    name: "还没想好",
    time: "2021-10-1",
    score: 0.0,
    userName: "李四",
    detail: "某些人在划水",
    status: 0,
    articleTitle: "基于猫娘的web课设系统",
    publication: "学生在线blog",
    meta: null,
    url: "http://web.wxyww.top",
  },
  {
    id: 30,
    name: "name非空",
    userName: "李四",
    time: "2022-12-02",
    score: 0.0,
    detail: " 测试",
    status: 0,
    articleTitle: "基于大腿的web课设",
    publication: "SCI",
    meta: null,
    url: "http://web.wxyww.top",
  },
];

export default function Research(props) {
  const nowTitle = useContext(TitleContext);

  const [rows, setRows] = useState(props.rows);
  const handleAcceptClick = (id) => {
    //这里实现通过申请接口
  };
  const handleRefuseClick = (id) => {
    //这里实现拒绝申请接口
  };
  const handleEdit = (newRow) => {
    //这是实现对于发展分的修改
    return newRow;
  };
  const columns = [
    {
      field: "id",
      headerName: "序号",
      flex: 1,
      editable: false,
    },
    {
      field: "userName",
      headerName: "申请人",
      flex: 2,
    },
    {
      field: "publication",
      headerName: "期刊/会议名称",
      flex: 4,
      renderCell: renderCellExpand,
    },
    {
      field: "time",
      type: "dateTime",
      headerName: "发表时间",
      // flex: 4,
      width: 150,
    },
    {
      field: "detail",
      headerName: "详情",
      hideable: false,
      // flex: 3,
      width: 120,
      renderCell: GetDetail,
    },
    {
      field: "score",
      headerName: "加分",
      flex: 1,
      editable: true,
    },
    {
      field: "articleTitle",
      headerName: "论文名称",
      renderCell: renderCellExpand,
      flex: 3,
    },
    {
      field: "url",
      headerName: "链接",
      // renderCell: GetChipType,
      flex: 2,
      renderCell: UrlRender,
      // width: 150,
    },
    {
      field: "status",
      headerName: "状态",
      renderCell: GetChipType,
      flex: 2,
    },
    {
      field: "actions",
      type: "actions",
      headerName: "操作",
      width: 100,
      cellClassName: "actions",
      getActions: ({ id }) => {
        return [
          <Tooltip title="通过">
            <GridActionsCellItem
              icon={<CheckIcon />}
              label="Delete"
              onClick={() => props.handleAcceptClick(id)}
              color="inherit"
            />
          </Tooltip>,
          <Tooltip title="驳回">
            <GridActionsCellItem
              icon={<CloseIcon />}
              label="重置密码"
              onClick={() => props.handleRefuseClick(id)}
              color="inherit"
            />
          </Tooltip>,
        ];
      },
    },
  ];

  return (
    <div>
      <Dataform
        processRowUpdate={props.processRowUpdate}
        editMode="cell"
        fileName="科研成果申请"
        columns={columns}
        rows={rows}
      />
    </div>
  );
}
